package duotai_text;


public class text {
    public static void fun(t1 name) {//发生向上转型
        name.Do();
    }

    public static void main(String[] args) {
        t1 zero = new t2("zero","qiaodaima");
        t2 one = new t2("hh", "做实验");
        fun(one);
        t3 two = new t3("wawo ", "鸟儿肥肉 ");
        fun(two);
        t4 three = new t4("buzhidai and buxiaode", "去泰国玩", "在520");
        t3 four = new t3("I  ", "go to evening classes");
        t1 arr[] = new t1[]{
                zero, one, two, three, four};
        System.out.println("-----");
        for (t1 name:arr) {//数组循环打印
            name.Do();
        }
        System.out.println("-----");
        //向下转型
        if(zero instanceof t2){
            t2 tmp = (t2) zero;
            tmp.do_what = "do nothing";
            tmp.name = " me";
            tmp.Do();
        }
        if (four instanceof t3) {
            t3 tmp = (t3) four;
            tmp.Do();
        }
    }
}
